uCalc API Version: 5.7.0-preview.1 Released: 7/30/2026
Warning
uCalc API Preview Release Notice:This preview documentation describes the intended behavior of the API. It is not fully accurate or complete.The current preview build contains incomplete features, unoptimized performance, and is subject to breaking changes.Use of the preview version in your production code is not recommended.
Product:
Class:
Retrieves the resulting data type of a parsed expression without needing to evaluate it.
The DataType method is an introspection tool that returns the resulting DataType of a parsed expression without actually evaluating it. This allows you to inspect the type of an expression before execution, enabling powerful features like static analysis, type validation, and conditional logic based on the expected output.
When an expression is parsed, its final return type is determined by a clear hierarchy:
ReturnType: If a DataType was provided in the Parse() call (e.g., uc.Parse("1+2", uc.DataTypeOf("String"))), that type is used.1 > 2 results in Boolean.'a' + 'b' results in String.1 + 2 * #i results in Complex.1.5 * 2 results in Double.Double by default.In statically typed languages like C#, typeof(int) gets a type at compile time, and myObject.GetType() gets an object's type at runtime after it has been created. uCalc's DataType method offers a different paradigm: it determines the type of a potential result from its unevaluated definition.
Without uCalc: You would have to parse the string yourself or evaluate it and then check the type of the result, which could be slow or trigger unwanted errors (like division by zero).
With uCalc: You can safely inspect the type first. This is crucial for:
Boolean for an if condition before running it.String or a Number and choose the appropriate display control (e.g., a label vs. a chart).ID: 41
using uCalcSoftware;
var uc = new uCalc();
Console.WriteLine(uc.Parse(" 3 + 6 * 10 ").DataType.Name);
Console.WriteLine(uc.Parse(" 'This ' + 'is a string' ").DataType.Name);
Console.WriteLine(uc.Parse(" 2 + 8 * #i / 2").DataType.Name);
Console.WriteLine(uc.Parse(" 10 + 2 > 3").DataType.Name);
double
string
complex
bool using uCalcSoftware; var uc = new uCalc(); Console.WriteLine(uc.Parse(" 3 + 6 * 10 ").DataType.Name); Console.WriteLine(uc.Parse(" 'This ' + 'is a string' ").DataType.Name); Console.WriteLine(uc.Parse(" 2 + 8 * #i / 2").DataType.Name); Console.WriteLine(uc.Parse(" 10 + 2 > 3").DataType.Name);
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
int main() {
uCalc uc;
cout << uc.Parse(" 3 + 6 * 10 ").DataType().Name() << endl;
cout << uc.Parse(" 'This ' + 'is a string' ").DataType().Name() << endl;
cout << uc.Parse(" 2 + 8 * #i / 2").DataType().Name() << endl;
cout << uc.Parse(" 10 + 2 > 3").DataType().Name() << endl;
}
double
string
complex
bool #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; int main() { uCalc uc; cout << uc.Parse(" 3 + 6 * 10 ").DataType().Name() << endl; cout << uc.Parse(" 'This ' + 'is a string' ").DataType().Name() << endl; cout << uc.Parse(" 2 + 8 * #i / 2").DataType().Name() << endl; cout << uc.Parse(" 10 + 2 > 3").DataType().Name() << endl; }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
Console.WriteLine(uc.Parse(" 3 + 6 * 10 ").DataType.Name)
Console.WriteLine(uc.Parse(" 'This ' + 'is a string' ").DataType.Name)
Console.WriteLine(uc.Parse(" 2 + 8 * #i / 2").DataType.Name)
Console.WriteLine(uc.Parse(" 10 + 2 > 3").DataType.Name)
End Sub
End Module
double
string
complex
bool Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() Console.WriteLine(uc.Parse(" 3 + 6 * 10 ").DataType.Name) Console.WriteLine(uc.Parse(" 'This ' + 'is a string' ").DataType.Name) Console.WriteLine(uc.Parse(" 2 + 8 * #i / 2").DataType.Name) Console.WriteLine(uc.Parse(" 10 + 2 > 3").DataType.Name) End Sub End Module